<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>用户登录</title>
</head>
<body>
    <form action="{:url('home/home/loginDo')}" method="post">
        用户名：<input type="text" name="username" placeholder="用户名" /><br>
        密码：<input type="password" name="password" placeholder="密码" /><br>
        <button type="submit" id="login">登录</button>
    </form>

<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
    // 登录操作
    $("#login").click(function () {
        $.ajax({
            url: "{:url('home/home/loginDo')}",
            type: "post",
            data: $("form").serialize(),
            dataType: "json",
            success: function (ret) {
                console.log(ret);
                if (ret == 1) {
                    alert("登录成功");
                } else {
                    alert("登录失败");
                }
            }
        });
        return false;
    });
</script>
</body>
</html>